package com.wsz.utils;

import org.springframework.security.core.context.SecurityContextHolder;

import java.util.Map;

public class SecurityContextUtils {
    public static Map<String,String> getUserInfo(){
        return (Map<String, String>) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }

    public static String getUserId(){
        Map<String, String> data = getUserInfo();
        return data.get("id");
    }

    public static String getUserUserName(){
        Map<String, String> data = getUserInfo();
        return data.get("username");
    }
}
